package com.motus.pm.daoImpl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.motus.pm.dao.DeptTaskDao;
import com.motus.pm.vo.PmDeptTask;

@Repository
public class DeptTaskDaoImpl extends BaseDaoImpl<PmDeptTask> implements DeptTaskDao {

	
	@SuppressWarnings("unchecked")
	@Override
	public List<PmDeptTask> getDeptTasksByDeptId(int deptId) {
		Session session=sessionFactory.getCurrentSession();
		String hql="from PmDeptTask where motusDept.deptid=?";
		Query query= session.createQuery(hql);
		query.setInteger(0, deptId);
		return query.list();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<PmDeptTask> getDeptTasksByDeptIdAndTaskState(int deptId,int taskState) {
		Session session=sessionFactory.getCurrentSession();
		String hql="from PmDeptTask where motusDept.deptid=? and deptTaskState=?";
		Query query= session.createQuery(hql);
		query.setInteger(0, deptId);
		query.setInteger(1, taskState);
		return query.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PmDeptTask> getDeptTasksByDeptIdAndMeetingType(int type,int deptId) {
		// TODO Auto-generated method stub
		Session session = sessionFactory.getCurrentSession();
		String hql = "from PmDeptTask where pmMeetingInfo.meetingType =?  and motusDept.deptid =? ";
		Query query = session.createQuery(hql);
		query.setInteger(0, type);
		query.setInteger(1, deptId);
		return query.list();
	}


}
